USE [QuanLyHopDong]
GO

/****** Object:  View [dbo].[KhoiLuongVatTuView]    Script Date: 9/4/2014 10:57:08 PM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO



ALTER view [dbo].[KhoiLuongVatTuView]
AS

select KLVT.Id, KLVT.HopDongId, KLVT.KhoiLuongId, KLVT.VatTuId, KLVT.SoLuong, KLVT.DonViTinh, KLVT.BenCap, 
	KLVT.ThiCong, KLVT.ThucTe, KLVT.GhiChu,
	VT.Name as TenVatTu, DVT.Name as TenDonViTinh,
	HD.SoHopDong, KLHD.MaTuyen,
	DD.Ma as DiemDau, DC.Ma as DiemCuoi,
	PXK.SoPhieu
from KhoiLuongVatTu KLVT
	inner join HopDong HD on KLVT.HopDongId = HD.Id
	left outer join KhoiLuongHopDong KLHD on KLVT.KhoiLuongId = KLHD.Id
	left outer join PhieuXuatKho PXK on KLVT.PhieuXuatKhoId = PXK.Id
	left outer join VatTu VT on KLVT.VatTuId = VT.Id
	left outer join DonViTinh DVT on KLVT.DonViTinh = DVT.Id
	left outer join DiaDiem DD on KLHD.DiemDauId = DD.Id
	left outer join DiaDiem DC on KLHD.DiemCuoiId = DC.Id



GO


